<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8" />
    <title>统一地图平台</title><link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
    <style>
        html,
        body,
        #mapui {
            width: 100%;
            height: 100%;
        }

        html,
        body {
            margin: 0;
            padding: 0;
        }
    </style>
</head>

<body>
    <div id="mapui"></div>

    <script src="./js_example/script/map.min.js"></script>
    <script src="./js_example/script/demo.js"></script>
    <script src="./js_thematic_map_example/script/jq/jquery.min.js"></script>
    <script src="./js_thematic_map_example/script/proj4.js"></script>
    <script>
        var amap = null;
        var that = this;
        map.Factory.create('mapui', {
            center: [114.321317, 30.398428],
            fullExtent: {
                xmin: 90.992204,
                ymin: 10.979711,
                xmax: 120.5338915,
                ymax: 50.543712
            },
            zoom: 10,
            projection: 'EPSG:4326',
            strategy: ['mapboxgl', 'openlayers'],
            style: style
        }, (o) => {
            amap = o;
            map.Factory.loadSpecialMap('mapv' , () =>{
                that.init(amap);
            })
        });


        function init(map) {
            $.get('./js_thematic_map_example/data/wuhan-car', function (rs) {
                console.log(rs)
                var data = [];
                var timeData = [];
                rs = rs.split("\n");
                var maxLength = 0;
                for (var i = 0; i < rs.length; i++) {
                    var item = rs[i].split(',');


                    var coordinates = [];
                    if (item.length > maxLength) {
                        maxLength = item.length;
                    }
                    for (j = 0; j < item.length; j += 2) {
                        if (item.length === 1) {
                            continue;
                        }
                        coordinates.push(proj4('EPSG:3857', 'EPSG:4326', [parseInt(item[j]), parseInt(item[j + 1])]));
                        timeData.push({
                            geometry: {
                                type: 'Point',
                                coordinates: proj4('EPSG:3857', 'EPSG:4326', [parseInt(item[j]), parseInt(item[j + 1])])
                            },
                            count: 1,
                            time: j
                        });
                    }


                    data.push({
                        geometry: {
                            type: 'LineString',
                            coordinates: coordinates
                        }
                    });

                }

                var dataSet = new special_mapv.DataSet(data);

                var options = {
                    strokeStyle: 'rgba(53,57,255,0.5)',
                    coordType: 'bd09mc',
                    // globalCompositeOperation: 'lighter',
                    shadowColor: 'rgba(53,57,255,0.2)',
                    shadowBlur: 3,
                    lineWidth: 3.0,
                    draw: 'simple'
                };

                var mapvLayer = new special_mapv.FmLayer(map, dataSet, options);

                var dataSet = new special_mapv.DataSet(timeData);

                var options = {
                    fillStyle: 'rgba(255, 250, 250, 0.2)',
                    coordType: 'bd09mc',
                    globalCompositeOperation: "lighter",
                    size: 1.5,
                    animation: {
                        stepsRange: {
                            start: 0,
                            end: 100
                        },
                        trails: 3,
                        duration: 5,
                    },
                    draw: 'simple'
                };
                var mapvLayer = new special_mapv.FmLayer(map, dataSet, options);
            });
        }
    </script>
</body>

</html>